var app = getApp();
var isclose=true;
var getList = function () {
  var _this = this;
  //调用应用实例的方法获取全局数据
  app.getUserInfo(function (userInfo) {
    wx.request({
      url: app.globalData.domain + 'api/wxapp_get?myopenId=' + userInfo.openId,
      success: function (res) {
        _this.setData({
          allActivity: res.data.project,
          time: (new Date()).Format('yyyy-MM-dd')
        });
        wx.hideNavigationBarLoading();
      }
    });
  });

};


Page({
  data: {

  },
  onLoad: function () {
    wx.setNavigationBarTitle({
      title: '我参与的项目'
    });
    getList.call(this);

  },
  onShow: function () {
    wx.showNavigationBarLoading();
    if (!isclose) {
      getList.call(this);
    }
  },
  onHide: function () {
    isclose = false;
  },
  onUnload: function () {
    isclose = true;
  },
  detail: function (e) {
    var id = e.target.dataset.id;
    if (!id) {
      return;
    }
    console.info(id);
    wx.navigateTo({
      url: '/pages/pjdetail/atdetail?id=' + id
    });
  },

});

Date.prototype.Format = function (fmt) {
  var o = {
    "M+": this.getMonth() + 1, //月份 
    "d+": this.getDate(), //日 
    "h+": this.getHours(), //小时 
    "m+": this.getMinutes(), //分 
    "s+": this.getSeconds(), //秒 
    "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
    "S": this.getMilliseconds() //毫秒 
  };
  if (/(y+)/.test(fmt))
    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  for (var k in o) {
    if (new RegExp("(" + k + ")").test(fmt)) {
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    }
  }
  return fmt;
}